package top.lucas9.wechat.push.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lucas9.wechat.push.entity.User;
import top.lucas9.wechat.push.service.impl.PushServiceImpl;
import top.lucas9.wechat.push.service.UserService;

/**
 * @author lucas9
 */
@RestController
@RequestMapping("/push")
public class PushController {
    @Autowired
    private PushServiceImpl pushServiceImpl;

    @Autowired
    private UserService userService;

    @GetMapping("/{userId}/{templateId}")
    public Boolean push(@PathVariable Long userId, @PathVariable String templateId) {
        User user = userService.getById(userId);
        return pushServiceImpl.push(user, templateId);
    }
}
